<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
Object obj=request.getSession().getAttribute("role_resource");
if(null==obj){
	response.setStatus(1000);
	return;
}
%> 
    
	<script type="text/javascript">
			//打印方式下拉列表
			print_store=new Ext.data.ArrayStore({
				fields: [
					"id", "text"
				],
				data: [
					["0", "滚筒"],["1","折叠"]
				]
			}),
			//外包商下拉列表
			epiboly_store=new Ext.data.JsonStore({
				root: "data",
	    		fields : [ "id", "name"],
				url : "epiboly!listAll.action"
			});
			//卡产品树数据源
			var tree_store=new Ext.data.JsonStore({
	    		root: "data",
	    		fields: ["id","text","leaf"],
	    		url: "product!ProdType.action"
	    	});
			//作业分配列表数据源
			var data_store=new Ext.data.JsonStore({
	    		root: "data",
	    		totalProperty: "total",
	    		fields: ["businpnt_no", "businpnt_name","city_no", "city_name", "card_no", "card_name", "print_type"],
	  			url:"epibCity!list.action"
	    	});
			
			var p1 = {
				id : "p1",
				xtype : "grid",
				stripeRows: true,
				loadMask : true,
				autoExpandColumn: "type",
				autoExpandMin: 200,
				store : data_store,
				headersDisabled: true,
				columns:[
			    	new Ext.grid.RowNumberer({header: "序号", width: 50}),
			    	{header: "外包商", 	dataIndex: "businpnt_name", width:200, menuDisabled: true},
			    	{header: "发行城市",	dataIndex: "city_name", width:200, menuDisabled: true},
			    	{header: "打印方式",	dataIndex: "print_type", id: "type", menuDisabled: true,
				    	renderer: function(input){
							if("0" == input) return "滚筒";
							else if("1" == input) return "折叠";
						}
					}
				],
				bbar: new Ext.ux.PagingToolbar( {
					pageSize : limit,
					store : data_store
				}),
				buttonAlign : "center",
				buttons:[{
					text:"查看详情", 
					handler: function(){
						var p1 = this.ownerCt.ownerCt;
						var panel = p1.ownerCt;
						var record = p1.getSelectionModel().getSelected();
						if (record){
							Ext.getCmp("p2").setParam(record.data);
							oper_type = "upd";
							panel.layout.setActiveItem(1);
						} else {
							Ext.Msg.show({
		   							title:"警告",
		   							msg: "请先选择一条记录!",
		   							buttons: Ext.Msg.OK,
		   							animEl: "elId",
		   							icon:Ext.MessageBox.WARNING
									});
							
						}	
					}
				}]
			};

			var p2 = {
				id:"p2",
				region: "north",
				border:false,
				xtype :"form",
				title: "外包商作业分配",
				height:125,
				bodyStyle : "padding:5px 5px 0",
				defaultType : "textfield",
				items: [
				{
					id: "paperCityCrd.card_name", 
					fieldLabel: "卡产品名称",	
					disabled:true,
					anchor: "100%"
				},{
					id: "paperCityCrd.businpnt_no",
					fieldLabel: "外包商名称",
					allowBlank: false,
					disabled:true,
					name: "paperCityCrd.businpnt_no",
					xtype: "billCombox",
					store: epiboly_store,
					valueField: "id",
					displayField: "name",
					listeners: {
						"select": function(){
							if(!Ext.getCmp("p2").getForm().isValid()){
								//Ext.Msg.alert("提示","验证不通过！");
								Ext.Msg.show({
		   							title:"警告",
		   							msg: "验证不通过!",
		   							buttons: Ext.Msg.OK,
		   							animEl: "elId",
		   							icon:Ext.MessageBox.WARNING
									});
								return;
							}
							var businpntno = this.value;
							var prodno = Ext.getCmp("paperCityCrd.card_no").getValue();
							Ext.Ajax.request({
								params: {
									"paperCityCrd.card_no": prodno,
									"paperCityCrd.businpnt_no": businpntno
						   	   	},
							   	url: "treeCheck!epibCity.action",
							   	success: function(res){
									var rootnode=Ext.getCmp("citypanel").getRootNode();
									rootnode.removeAll();
									rootnode.appendChild(eval("("+res.responseText+")"));
							   	}
							});
						}
					}
				},{
					id: "paperCityCrd.print_type", 
					fieldLabel: "打印方式",	
					name: "paperCityCrd.print_type",
					xtype: "billCombox",
					store: print_store,
					allowBlank: false,
					disabled:true,
					anchor: "100%"
				}],
			setParam: function(data){
				var p2 = this;
				Ext.getCmp("paperCityCrd.card_name").setValue(data.card_name);
				Ext.getCmp("paperCityCrd.businpnt_no").setValue(data.businpnt_no);
				Ext.getCmp("paperCityCrd.print_type").setValue(data.print_type);
				
				Ext.Ajax.request({
					params: {
						"paperCityCrd.card_no": data.card_no,
						"paperCityCrd.businpnt_no": data.businpnt_no
			   	   	},
				   	url: "treeCheck!epibCity.action",
				   	success: function(res){
						var rootnode=Ext.getCmp("citypanel").getRootNode();
						rootnode.removeAll();
						rootnode.appendChild(eval("("+res.responseText+")"));
				   	}
				});
			}
			};
			
			var p3=new Ext.Panel({
				layout:"border",
				items:[p2,{
					region:"center",
					xtype: "billTreePanel",
				    id:"citypanel",
					autoScroll:true,
					title: "发行城市设置",
					rootVisible:false,
					root:{
						id:"root"
					}
				}],
				buttonAlign : "center",
				buttons:[{text:"返回", handler: function(){
					Ext.getCmp("aaa").layout.setActiveItem(0);
				}
			}]
		});

		var epicity_pel = new Ext.Panel( {
				id:"master_panel",
				border : false, 
				layout: "border",
				items:[{
					id:"epibCityTree",
					xtype : "billTreePanel",
					dataUrl : "tree!product.action",
					root : new Ext.tree.AsyncTreeNode( {
						id : "root",
						expanded : true
					// 自动展开节点
					}),
					listeners : {
						"click"	: function(node) {
							tree_store.load({params:{node:node.attributes.id}});
							if(node.isLeaf()) {
								Ext.getCmp("aaa").layout.setActiveItem(0);
								data_store.baseParams = data_store.baseParams || {};
								data_store.baseParams["paperCityCrd.card_no"] = node.attributes.id;
								data_store.load({params:{start : 0,limit :limit}});
							}
						}
					}
				}, {
					id:"aaa",
					region: "center",
					border : false, 
					layout:"card",
					activeItem:0,//显示第一个容器
					items: [p1, p3]
				} ]
			});
			epiboly_store.load();
			
	
	var CenterPanel=Ext.getCmp("CenterPanel");
	CenterPanel.removeAll();
	CenterPanel.add(epicity_pel);
	CenterPanel.doLayout();
	</script>
    
